package com.multi.thread.chapter06.demo03;

public class Singleton {
	
	private Singleton() {};
	
	private static class SingletonHandler {
		private static Singleton singleton = new Singleton();
	}
	
	public static Singleton getInstance() {
		return SingletonHandler.singleton;
	}
	
	private static class MyThread extends Thread {
		@Override
		public void run() {
			System.out.println(Singleton.getInstance().hashCode());
		}
	}
	
	public static void main(String[] args) {
		MyThread t1 = new MyThread();
		MyThread t2 = new MyThread();
		MyThread t3 = new MyThread();
		t1.start();
		t2.start();
		t3.start();
	}

}
